package com.exercises;


class Exercise1744 {
    public static void main(String[] args) {
        System.out.println(!(3 > 23 || 18 < 18));
    }


    public boolean[] canEat(int[] candiesCount, int[][] queries) {
        //前缀和
        int length = candiesCount.length;
        //类型i的糖果最多可以吃到多少天
        long[] typeSum = new long[length];
        typeSum[0] = candiesCount[0];
        for (int i = 1; i < length; i++) {
            typeSum[i] = typeSum[i - 1] + candiesCount[i];
        }


        length = queries.length;

        boolean[] result = new boolean[length];
        for (int i = 0; i < length; i++) {
            int[] querie = queries[i];
            int favoriteType = querie[0], favoriteDay = querie[1], dailyCap = querie[2];
            //x1:每天吃1颗 x2=每天吃最多颗
            //x1-x2 能吃的糖果分布区间
            long x1 = favoriteDay + 1;
            long x2 = x1 * dailyCap;
            //(y1+1)到y2 类型y2的糖果最多能吃的天数
            long y1 = favoriteType == 0 ? 1 : typeSum[favoriteType - 1] + 1;
            long y2 = typeSum[favoriteType];
            result[i] = !(x1 > y2 || x2 < y1);
        }
        return result;

    }


}
